<extend name="Public/layout"/>
<block name="head">
          <link rel="stylesheet" href="__PUBLIC__assets/layer_mobile/need/layer.css">
          <link rel="stylesheet" href="__PUBLIC__assets/swiper/css/swiper.min.css">
          <link rel="stylesheet" href="__PUBLIC__css/get-money.css">
          <script src="__PUBLIC__assets/swiper/js/swiper.jquery.min.js"></script>
<style type="text/css">
.footer{
    display: none !important;
}
</style>
    <script>
        (function (window) {
            var docEl = document.documentElement;
            var h;

            function setUnitA() {
                window.rem = docEl.getBoundingClientRect().width / 10;
                docEl.style.fontSize = window.rem + 'px';
            }

            window.addEventListener('resize', function () {
                clearTimeout(h);
                h = setTimeout(function () {
                    setUnitA();
                }, 300);
            }, false);

            window.addEventListener('pageshow', function (e) {
                if (e.persisted) {
                    clearTimeout(h);
                    h = setTimeout(function () {
                        setUnitA();
                    }, 300);
                }
            }, false);

            setUnitA();

        })(window);
    </script>
    <script src="__PUBLIC__js/util.js"></script>
</block>
<block name="main">

        <div class="header">
            <div class="header-box">
                <div class="bank">
				
                    <div class="bank-icon"><span class="icon"></span><notempty name='user_info.bank_card_small'>已绑定银行卡<else/>未绑定银行卡</notempty></div>
                    <div class="wrap">
                        <!-- 绑定银行卡 -->
                        <div class="bind-card <notempty name='user_info.bank_card_small'> none </notempty>" onclick="location.href='/Home/Person/bind_bank_card'" >绑定银行卡</div>
                        <!-- 已绑定银行卡 -->
                        <div class="bind-card-on">
                            <notempty name="user_info.bank_card_small">
                                <div class="xing"><span>****</span><span>****</span><span>****</span><div class="card"><span>{$user_info.bank_card_small}</span></div></div>
                            </notempty>
                        </div>                        
                    </div>
                </div>
            </div>
            <div class="list-item">
                <div class="list-item-box">
                    <div class="list-item-info">
                            <dt>{$user_info.balance}</dt>
                            <dd>投资返利余额<span>(元)</span></dd>
                        </div>
                        <div class="list-item-info">
                            <dt>{$user_info.prize_balance}</dt>
                            <dd>邀请返利余额<span>(元)</span></dd>
                        </div>
                </div>
            </div>
            <div class="list-item-table">
                <div class="list-item-box">
                    <div class="list-item-info">
                        <dt><span class="icon"></span>投资返利提现</dt>
                        <dd>通过投资所获得的返利，提现单笔最低1元；</dd>
                    </div>
                    <div class="list-item-info">
                        <dt><span class="icon"></span>邀请返利提现</dt>
                        <dd>通过邀请所获得的返利，提现单笔最低50元；</dd>
                    </div>
                </div>
            </div>      
            <div class="select-list">
                <div class="select-text">选择提现余额：</div>
                <div class="select-info">
                    <input type="radio" name="radio" value="1" id="check" class="regular-checkbox" checked/><label for="check"></label>投资返现提现
                    <input type="radio" name="radio" value="2" id="check1" class="regular-checkbox"/><label for="check1"></label>邀请返现提现
                </div>
            </div> 
            <div class="number">
                <div class="numbers">提现金额<input type="text" name="cash_val" id="" placeholder="请输入提现金额"></div>
            </div>
            <div class="tips"><div class="tips-number">每天免费提现次数：<b>1</b>次</div><div class="explain"><a href="#" class="explain-popup">提现说明</a></div></div>   
            <div class="btn"><button class="ck"  <notempty name="user_info.bank_card"> onclick="getCash()" <else/>onclick="no_bank_card()" </notempty>   >申请提现</button></div>
            <!-- <div class="explain"><a href="#" class="explain-popup">提现说明</a></div> -->
        </div>
</block>
<block name="js">
<script>
      var pageii;
        var success;
        var error;
        var explain;

    //$(function(){
      
        // 提现申请弹窗
        //$('.ck').click(function(){
		function getCash() {
            var cash_val = parseFloat($('input[name="cash_val"]').val());
            //获取手续费
            if (cash_val == '' || cash_val == undefined || cash_val == null) {
                layer.closeAll();
                layer.open({
                    content: '请输入提现金额'
                    ,skin: 'msg'
                    ,time: 2
                });
                return
            }

            if (!/^\d+$/.test(cash_val)) {
                layer.closeAll();
                layer.open({
                    content: '提现金额只能是数字'
                    ,skin: 'msg'
                    ,time: 2
                });
                $('input[name="cash_val"]').val('')
                return
            }
            var id = '{$_SESSION["user"]["id"]}'
            $.post('/Home/Person/get_charge',{
                id:id,
            },function(res){
                if(res.err==1){
                     charge=1;
                }else{
                     charge='0.00';
                }
                 var content='<div class="popuo-get">'+
                    '<div class="icon-close"><span class="close" onclick="layer.closeAll()"></span></div>'+
                    '<div class="title">提现确认</div>'+
                        '<div class="tips-text">'+
                            '<ul>' +
                                    '<li>提现金额：<span>'+cash_val+'</span>元</li>' +
                                    '<li>提现金额：<span>'+charge+'</span>元</li>' +
                                    '<li>到账时间：您的提现将在T+1日后到账</li>' +
                                '</ul>' +
                        '</div>'+
                        '<footer>' +
                            '<ul>' +
                                '<li class="btn close" onclick="layer.closeAll()">取消</li>'+
                                '<li class="btn-error" onclick="withdrawals()">确认</li>'
                                // 如果提交成功 class为btn-success 提交失败 class为btn-error
                            '</ul>' +
                        '</footer>';
                    '</div>';
                    pageii = layer.open({
                        type: 1
                        ,content: content
                        ,anim: 'up'
                        ,className: 'popuo-sq'
                    });

            })
        }
    //    })

           //确认提现
function withdrawals() {
    var affirmdepo = $('input[name="cash_val"]').val();
    var val = $('.regular-checkbox:checked').val();
    if (!isNaN(affirmdepo)) {
        $.post('/Home/Person/withdrawals', {
            affirmdepo: affirmdepo,
            type:val
        }, function (res) {
             
            if (res.err == 0) {
                    layer.close(pageii);
                    var content='<div class="success">'+
                        '<div class="icon-close"><span class="close" onclick="layer.closeAll()"></span></div>'+
                        '<div class="icon-title"><span></span></div>'+
                        '<div class="get-success">提交申请成功！</div>'+
                        '<div class="get-success-tips">您的提现将在<span>T+1</span>日后到账，请注意查收！</div>'+
                        '<footer>' +
                            '<ul>' +
                                '<li class="btn close" onclick="layer.closeAll()">完成</li>'
                            '</ul>' +
                        '</footer>';
                        '</div>';
                        success = layer.open({
                        type: 1
                        ,content: content
                        ,anim: 'up'
                        ,className: 'popuo-get-success'
                        ,end:function(){
                        location.reload();
                        
                    }
                    });               


            }else{
                layer.close(pageii);
                var content='<div class="success">'+
                    '<div class="icon-close"><span class="close" onclick="layer.closeAll()"></span></div>'+
                    '<div class="icon-title-error"><span></span></div>'+
                    '<div class="get-success">提交申请失败！</div>'+
                    '<div class="get-success-tips">'+res.msg+'！</div>'+
                    '<footer>' +
                        '<ul>' +
                            '<li class="btn close" onclick="layer.closeAll()">完成</li>'
                        '</ul>' +
                    '</footer>';
                    '</div>';
                    error = layer.open({
                    type: 1
                    ,content: content
                    ,anim: 'up'
                    ,className: 'popuo-get-success'
                });         

            }
        });
    } else {
        layer.open({
            content:"请输入正确的提现金额"
            ,skin: 'msg'
            ,time: 1 //2秒后自动关闭
          });
    }
}


        // 提现说明弹窗
        $('body').on('click','.explain',function(){
            var content='<div class="explains">'+
                '<div class="icon-close"><span class="close" onclick="layer.closeAll()"></span></div>'+
                '<div class="title-explain">提现说明</div>'+
                '<div class="swiper-container">'+
                    '<div class="swiper-wrapper">'+
                        '<div class="swiper-slide">'+
                        '<p>1.投资返利单笔提现金额最低1元；邀请返利单笔提现最低50元。（符合提现规则的返利金额可一起提现</p>'+
                        '<p>2.国家法定节假日提现到帐时间将顺延至假期结束后的第一个工作日，部分地方性商业银行会在1-3个工作日内到账，具体提现安排以网站最新公告为准。</p>'+
                        '<p>3.用户提现时需确认银行卡姓名及预留手机号与8号金融街认证信息一致，否则将会导致提现失败。</p>'+
                        '<p>4.用户每天可享1次免费提现，超出后按单笔提现手续费1元，提现手续费将在到账金额扣除。</p>'+
                        '<p>5.如遇银行升级等特殊原因，提现金额可能会延迟到账。</p>'+                        
                        '</div>'+
                    '</div>'+
                    '<div class="swiper-scrollbar"></div>'+
                '</div>'+
                '<footer>' +
                    '<ul>' +
                        '<li class="btn close" onclick="layer.closeAll()">知道了</li>'
                    '</ul>' +
                '</footer>';
                '</div>';
                explain = layer.open({
                type: 1
                ,content: content
                ,anim: 'up'
                ,className: 'popuo-explain'
            });               
        })
        // 关闭弹窗
        $('body').on('click','.close',function(){
            layer.close(pageii);
        })
        $('body').on('click','.close',function(){
            layer.close(success);
        })
        $('body').on('click','.close',function(){
            layer.close(error);
        })
        $('body').on('click','.close',function(){
            layer.close(explain);
        })
        var swiper = new Swiper('.explains>.swiper-container', {
            direction: 'vertical',
            slidesPerView: 'auto',
            freeMode: true,
            scrollbar: {
                el: '.swiper-scrollbar',
            },
            mousewheel: true,
        });
		
		
        function no_bank_card() {
            layer.open({
                content: "您还未绑定银行卡,请先绑定银行卡！"
                , btn: ['前往', '取消']
                , yes: function (index) {
                    location.href = "/Home/Person/bind_bank_card"
                }
            });
        }
		
		
</script>
</block>